import { Button, Form, message, Radio } from 'antd';
import router from 'next/router';
import { ReactNode, useEffect, useState } from 'react';
import an58 from '@mmstudio/an000058';
import api from '../../../atoms/api';
import { Message as M1, Result as R1 } from '../../api/registration/registration1/save/api.api';

export default function Save() {
	const [appr, setappr] = useState('');//审批状态
	const [rect, setrect] = useState(''); //原因
	return <>
		<Form.Item label="审批意见:">
			<Radio.Group value={appr} onChange={(e) => {
				setappr(e.target.value);
			}}>
				<Radio value={'通过'}>通过</Radio>
				<Radio value={'驳回'}>驳回</Radio>
			</Radio.Group>
		</Form.Item>
		<Form.Item label='驳回意见:' className='s03'><input className='s04' placeholder='驳回时填写' value={rect} onChange={(e) => {
			setrect(e.target.value);
		}} />
		</Form.Item>
		<div className='s01'>
			<Button shape='round' type='primary' onClick={async () => {
				const ret = await an58<R1, M1>(api['/api/registration/registration1/save/api'], 'post',
					{
						approvalstatus: appr,
						rejectionreasons: rect
					});
				if (ret.ok === true) {
					message.success('保存成功');
				} else {
					message.error('保存失败');
				}
			}} >保存</Button></div>
		<style jsx>{`
.s01{
display: flex;
justify-content: center;
}
.s04{
height: 100px;
width: 90%;
}
`}</style>
	</>;
}


